package com.z.front;

import com.z.admin.service.BaseSercvice;
import com.z.common.base.PageTableRequest;
import com.z.common.base.ResponseCode;
import com.z.common.base.Results;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseController<M extends BaseSercvice<T>, T> {
    @Autowired
    private M iService;

    @PostMapping("list")
    @ResponseBody
    public Results list() {
        try{
            Map<String, Object> map = new HashMap<>();
            List<T> list = iService.getBaseMapper().selectByMap(map);
            return Results.success(list.size(), list);
        }catch (Exception e ){
            return Results.failure(ResponseCode.error.getCode(), e.getMessage());
        }
    }



}
